package taskTracker.ui.lwuit;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.Vector;

import javax.microedition.midlet.MIDlet;

import taskTracker.Project;
import taskTracker.Tag;
import taskTracker.Task;
import taskTracker.TimeEntries;

import com.sun.lwuit.Display;
import com.sun.lwuit.events.ActionEvent;
import com.sun.lwuit.events.ActionListener;
import com.sun.lwuit.plaf.UIManager;
import com.sun.lwuit.util.Resources;

public class MainScreen extends MIDlet implements ActionListener {

	/**Holds the projects stored in the program*/
	private Vector projects;

	/**The list that holds all Projects*/
	private ProjectListUI projectList;
	
	public MainScreen() {
		Display.init(this);
		try {
			Resources r = Resources.open("/LWUITtheme.res");
			UIManager.getInstance().setThemeProps(r.getTheme("LWUITDefault"));
		} catch (IOException ioe) {
			// Do something here.
		}
	}
	
    public void startApp() {
    	projects = Project.loadData();
    	this.projectList = createFormLists(projects);
    	this.projectList.show();
    }

    private ProjectListUI createFormLists(Vector projects2) {
		this.projectList = new ProjectListUI(projects2);
		return this.projectList;
	}

	public void pauseApp() {
    	
    }

    public void destroyApp(boolean unconditional) {
    	Project.saveData(projects);
    }

    public void actionPerformed(ActionEvent ae) {
    	System.out.println("Action performed:"+ae.getCommand());
    }

}
